package com.example.springvalidatesample1;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import org.hibernate.validator.constraints.Length;
import org.springframework.context.annotation.Primary;
import org.springframework.validation.annotation.Validated;

@Entity
@Table(name = "bus")
public class Car {

    @NotEmpty(message = "车名称不能为空")
    @Length(min = 2, max = 5, message = "车名称必须在2-5之间")
    @Column(name = "name")
    private String name;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private long id;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
